package client.whiteboard.controller;
import client.whiteboard.model.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import client.whiteboard.view.IDisplay;
public class DisplayController extends Controller implements ActionListener, MouseListener, MouseMotionListener
{
	private IManager _manager;
	private IDisplay _display;
	public DisplayController()
	{
		
	}
	public void setManager(IManager manager)
	{
		_manager = manager;
	}
	public void setDisplay(IDisplay display)
	{
		_display = display;
	}
	public void mouseMoved(MouseEvent e)
	{
		_manager.mouseMove(e.getX(), e.getY());
		updateDisplay();
	}
	public void mouseReleased(MouseEvent e)
	{
		_manager.mouseUp(e.getX(), e.getY());
		updateDisplay();
	}
	public void mousePressed(MouseEvent e)
	{
		_manager.mouseDown(e.getX(), e.getY());
		updateDisplay();
	}
	public void updateDisplay()
	{
		if(_display != null)
		{
			_display.update();
		}
	}
	public void mouseClicked(MouseEvent e){}
	public void mouseEntered(MouseEvent e){}
	public void mouseExited(MouseEvent e){}
	public void mouseDragged(MouseEvent e)
	{
		_manager.mouseDrag(e.getX(), e.getY());
		updateDisplay();
	}
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		_manager.buttonPressed(e.getActionCommand());
	}
}
